/* eslint-disable max-statements */ import type { ParsedUrlQuery } from 'querystring'; import type { GetStaticPaths, GetStaticProps } from 'next'; import Head from 'next/head'; import NextImage from 'next/image'; import { useRouter } from 'next/router'; import Script from 'next/script'; import { useIntl } from 'react-intl'; import { getLayout, Heading, LinksWidget, type MetaItemData, PageLayout, PostsList, Time, } from '../../components'; import { getAllTopicsSlugs, getTopicBySlug, getTopicsPreview, getTotalTopics, } from '../../services/graphql'; import styles from '../../styles/pages/blog.module.scss'; import type { NextPageWithLayout, PageLink, Topic } from '../../types'; import { ROUTES } from '../../utils/constants'; import { getLinksItemData, getPageLinkFromRawData, getPostsWithUrl, getSchemaJson, getSinglePageSchema, getWebPageSchema, } from '../../utils/helpers'; import { loadTranslation, type Messages } from '../../utils/helpers/server'; import { useBreadcrumb, useSettings } from '../../utils/hooks'; export type TopicPageProps = { currentTopic: Topic; topics: PageLink[]; translation: Messages; }; const TopicPage: NextPageWithLayout = ({ currentTopic, topics, }) => { const { content, intro, meta, slug, title } = currentTopic; const { articles, cover, dates, seo, thematics, website: officialWebsite, } = meta; const intl = useIntl(); const { items: breadcrumbItems, schema: breadcrumbSchema } = useBreadcrumb({ title, url: `${ROUTES.TOPICS}/${slug}`, }); const headerMeta: (MetaItemData | undefined)[] = [ { id: 'publication-date', label: intl.formatMessage({ defaultMessage: 'Published on:', description: 'TopicPage: publication date label', id: 'KV+NMZ', }), value: